//
//  ScanViewController.swift
//  Ofo-demo
//
//  Created by 张彦辉 on 2017/5/23.
//  Copyright © 2017年 张彦辉. All rights reserved.
//

import UIKit
import swiftScan

class ScanViewController: LBXScanViewController {

    @IBOutlet weak var panelView: UIView!
    
    var isFlashOn = false
    
    override func viewDidLoad() {
        super.viewDidLoad()

        self.title = "扫码用车"
        self.navigationController?.navigationBar.barStyle = .blackTranslucent
        scanStyle?.anmiationStyle = .NetGrid
        scanStyle?.animationImage = #imageLiteral(resourceName: "bg_QRCodeLine")
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        self.view.bringSubview(toFront: panelView)
    }
    override func viewWillDisappear(_ animated: Bool) {
        super.viewWillDisappear(animated)
        self.navigationController?.navigationBar.barStyle = .default
        self.navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: .plain, target: self, action: nil)
    }
    
    @IBAction func flashBtnClick(_ sender: UIButton) {
        isFlashOn = !isFlashOn
        scanObj?.changeTorch()
        if isFlashOn {
            sender.setImage(#imageLiteral(resourceName: "btn_enableTorch"), for: .normal)
        } else {
            sender.setImage(#imageLiteral(resourceName: "btn_unenableTorch_w"), for: .normal)
        }
    }

    override func handleCodeResult(arrayResult: [LBXScanResult]) {
        
    }

}
